<template>
  <div>
    <div style="float: left"><el-button size="small">上报</el-button></div>

    <div style="float: right">
      <el-input v-model="obj.province"  placeholder="请输入内容"></el-input>
    </div>

    <el-table :data="dataList.list" style="width: 100%">
      <el-table-column
        fixed="left"
        align="center"
        prop="id"
        label="编号"
        width="50"
      >
      </el-table-column>
      <el-table-column align="center" prop="country" label="国家">
      </el-table-column>
      <el-table-column align="center" prop="province" label="省份">
      </el-table-column>
      <el-table-column align="center" prop="city" label="市"> </el-table-column>
      <el-table-column align="center" prop="area" label="区"> </el-table-column>
      <el-table-column align="center" prop="confirmed" label="现有确诊">
      </el-table-column>
      <el-table-column align="center" prop="suspected" label="疑似">
      </el-table-column>
      <el-table-column align="center" prop="dead" label="死亡">
        <template v-slot="scope">
          <el-tag type="danger">{{ scope.row.dead }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="cure" label="治愈">
        <template v-slot="scope">
          <el-tag type="success">{{ scope.row.cure }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="severe" label="累计确诊">
      </el-table-column>
      <el-table-column align="center" prop="outside" label="境外输入">
      </el-table-column>
      <el-table-column
        fixed="right"
        align="center"
        prop="inputTime"
        label="录入时间"
        width="180"
        ><template v-slot="scope">
          <div>{{ scope.row.inputTime | dateFMT }}</div>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      layout="prev, pager, next"
      :total="dataList.total"
      :page-size="obj.pageSize"
      :current-page="obj.page"
      @current-change="change_page"
    >
    </el-pagination>
  </div>
</template>


<script>
// 从vuex中导入辅助函数
// 辅助函数:帮助我们快速获取状态机中的变量或方法
import { mapActions, mapState } from "vuex";
export default {
  // 计算属性
  computed: {
    // 从dataList.js文件的state中获取dataList变量
    ...mapState("dataList", ["dataList"]),
  },
  data() {
    return {
      obj: {
        page: 1,
        pageSize: 10,
      },
      total: 100,
    };
  },
  created() {
    this.page_query(this.obj);
  },
  watch:{
    obj:{
      handler:function(){
        this.page_query(this.obj)
      },
      deep:true
    }
  },

  methods: {
    // 从dataList.js文件的action中获取page_query方法
    ...mapActions("dataList", ["page_query"]),
    change_page(val) {
      this.obj.page = val;
      console.log(val);
    },
  },
};
</script>